//
//  RegisterViewController.m
//  Four_Fit
//
//  Created by xalo on 16/7/13.
//  Copyright © 2016年 xmaz. All rights reserved.
//

#import "RegisterViewController.h"
#import "InitViewController.h"
#import "RegisterModel.h"
/**
 *  注册界面
 */

@interface RegisterViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *idTextField;          //手机号
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;    //密码
@property (weak, nonatomic) IBOutlet UITextField *validataTextField;    //验证码
@property (weak, nonatomic) IBOutlet UIButton *mationBtn;               //获取验证码
@property (weak, nonatomic) IBOutlet UIButton *registerBtn;             //注册
@property (weak, nonatomic) IBOutlet UIButton *QQLoginBtn;              //QQ第三方登录
@property (weak, nonatomic) IBOutlet UIButton *WeboBtn;                 //微博第三方登录


@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.validataTextField.keyboardType = UIKeyboardTypeNumberPad;
   
    self.idTextField.clearsOnBeginEditing = YES;
    self.validataTextField.clearsOnBeginEditing = YES;
    self.idTextField.returnKeyType = UIReturnKeyNext;
    self.passwordTextField.returnKeyType = UIReturnKeyNext;
    self.passwordTextField.delegate = self;

}


- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    
    self.passwordTextField.clearsOnBeginEditing = YES;
    
    return YES;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField {
    
    if ((self.passwordTextField.clearsOnBeginEditing = YES)) {
        
        self.passwordTextField.secureTextEntry = YES;
    }
}
//获取验证码
- (IBAction)mationBtnAction:(id)sender {
    
    [[QZRequestManager sharedManager]fetchDataWithUrl:[NSString stringWithFormat:@"http://ws.sythealth.com/wsbyte/fit/v4/sms/validatorcode?account=%@&form=0&tokenid=tokenid_undefined",self.idTextField.text] parameters:@{@"account":self.idTextField.text,@"form":@"0",@"tokenid":@"tokenid_undefined"} method:@"GET" needToCaches:NO fetchData:^(NSData *data) {
        
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@",dic);
    } updateUI:^{
        
        
        
    }];
}

//注册
- (IBAction)registerBtnAction:(id)sender {
    
    [[QZRequestManager sharedManager]fetchDataWithUrl:@"http://ws.sythealth.com/ws/fit/v4/user/register" parameters:@{@"data":@{@"account":self.idTextField.text,@"password":self.passwordTextField.text,@"tokenid":@"tokenid_undefined",@"validatorcode":self.validataTextField.text,@"devicesystem":@"ios"}} method:@"POST" needToCaches:NO fetchData:^(NSData *data) {
        
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@",dic);
        
    } updateUI:^{
        
    }];
}

//QQ第三方
- (IBAction)QQLoginBtnAction:(id)sender {
}

//微博第三方
- (IBAction)WeboLoginBtnAction:(id)sender {
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
